Using GdPicture.NET
Summary
After installation, we recommend you to have a look at the samples directory to get some featured examples of the GdPicture.NET usage.
The GdPicture.NET suite includes 10 main classes: GdPictureImaging, GdViewer, GdPicturePDF, GdPictureDocumentUtilities, Annotation, AnnotationManager, AnnotationEditor, BookmarksTree, LicenseManager & ThumbnailEx. See below for how to instantiate objects from these classes.
Notes:
- To install the GdPicture.NET suite on client computers, please see the Redistributing GdPicture.NET section.
- GdPicture.NET requires the .NET Framework 2.0 or higher.
- GdPicture.NET core is compiled using the AnyCPU Platform target.
Adding a reference to GdPicture.NET into your application
- Start Visual Studio .NET
- Begin a new project using your favorite programming language.
- Select Project / Add Reference...
- Select the Browse tab and select the GdPicture.NET dll library which can be found on [INSTALLATION FOLDER]\Redist\Framework X.X\GdPicture.NET.dll
- Add a link to the GdPicture Namespace where you want to use the DLL
- In C#, add the appropriate using directive to the code file(s) where you want to use the DLL: using GdPicture14;
- In VB.NET, add the appropriate Imports directive to the code file(s) where you want to use the DLL: Imports GdPicture14
Using a GdPictureImaging object into your application
Before starting, make sure you successfully done both first and second steps.
You need to instantiate each GdPictureImaging object by code.
C# example |
Copy Code |
---|---|
private void button1_Click(object sender, EventArgs e) { GdPictureImaging oGdPictureImaging = new GdPictureImaging(); int ImageID = oGdPictureImaging.CreateGdPictureImageFromFile("c:\\test.jpg"); oGdPictureImaging.SaveAsJP2(ImageID, "c:\\test.jp2",64); oGdPictureImaging.ReleaseGdPictureImage(ImageID); } |
Visual Basic .NET example |
Copy Code |
---|---|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oGdPictureImaging As New GdPictureImaging Dim ImageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("c:\test.jpg") oGdPictureImaging.SaveAsJP2(ImageID, "c:\test.jp2", 64) oGdPictureImaging.ReleaseGdPictureImage(ImageID) End Sub |
Using a GdViewer object into your application
Before starting, make sure you successfully done both first and second steps.
You can instantiate a GdViewer object by code :
Visual Basic .NET example |
Copy Code |
---|---|
Imports GdPicture14 Public Class Form1 Private WithEvents Gdviewer1 As New GdViewer Private Sub form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load Controls.Add(Gdviewer1) Gdviewer1.Left = 202 Gdviewer1.Top = 32 Gdviewer1.Width = 780 Gdviewer1.Height = 545 End Sub End Class |
Or simply dragging a GdViewer item from the Visual Studio Toolbox to your Windows Form :
Right-click into the Toolbox Items and select "Add/Remove Items" for Visual Studio 2003 or "Choose Items" for Visual Studio 2005 & later.
- Select the .NET Framework Components tab
- Click on the Browse... button
- Select the GdPicture.NET dll which can be found on C:\Program Files\GdPicture.NET 14\Redist\Framework X.X\GdPicture.NET.dll
- Now you will be able to select a GdViewer Item from the Toolbox in order to draw it within your forms.
C# example |
Copy Code |
---|---|
private void button1_Click(object sender, EventArgs e) { this.gdViewer1.DisplayFromFile("c:\\test.jpg"); } |
VB.NET example |
Copy Code |
---|---|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.GdViewer1.DisplayFromFile("c:\test.jpg") End Sub |
Displaying a GdPicture Image handled by a GdPictureImaging object to a GdViewer object.
The GdPictureImaging class can create GdPicture Image from file, memory RAW, scanner...
If you want to display in real time a GdPicture Image handled by a GdPictureImaging object you can use the DisplayFromGdPictureImage method of the GdViewer class.
This example assumes you already have a GdPictureImaging object named oGdPictureImaging and a GdViewer object drawn on your form named GdViewer1.
VB.NET example |
Copy Code |
---|---|
Dim ImageID As Integer = oGdPictureImaging.CreateImageFromFile("c:\test.jpg") GdViewer1.DisplayFromGdPictureImage(ImageID) |
If later in your code, you want to draw something on the image (like text) and display the modification without reloading the image you can do:
VB.NET example |
Copy Code |
---|---|
oGdPictureImaging.DrawText(ImageID, "Hello World!", 50, 50, 10, FontStyle.FontStyleBold, Color.Red, "Arial", True) GdViewer1.Refresh() |